<?php
require './include/global.php';
require './include/validate.php';
require './include/all_left.php';
require_once './include/advisory_db.php';
include("FCKeditor/fckeditor.php") ;
$status = $_SESSION['status'];
if('Premium' == $status) {
	$jobcontact = array("1" => 'Candidates', '2' => 'Recruiters');
} else {
	$jobcontact     = array('2' => 'Network');
	$jobcontact_tip = array('2'=>'Check here to post this job to the network for view by other recruiter members.');
}

if($_SESSION[usertype] != "employer" && $_SESSION[usertype] != "recruiter"){
	echo "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\">";
	exit;
}
accessblock(array("Trial","Expired"));

//print_r($_SESSION);
$smarty->compile_check = true;
include("./check/checkpostjob.php");
$_GET[id] = $_SESSION[uid];

$get = $_SESSION[usertype];

$smarty->display('header.tpl');
//'option'=>$jobcategory

if(empty($_POST)){
	if($_SESSION[usertype]=='recruiter'){
		$sql  = "SELECT * FROM pa_recuiter WHERE rc_id = '".$_SESSION[uid]."'";	
        $list = $DB->fetch_one_array($sql);
        $_POST[jo_copname]		  =  $list[rc_copname] ;
		$_POST[jo_copurl]		  =  $list[rc_website];
		$_POST[jo_priname]		  =  $list[rc_fname]." ".$list[rc_lname];
		$_POST[jo_priemail]		  =  $list[rc_email];
		$_POST[jo_priphone]		  =  $list[rc_phone];
		$_POST[jo_address]	      =	 $list[rc_address1];
		$_POST[jo_city]			  =  $list[rc_city];
		$_POST[jo_state]		  =  $list[rc_state];
		$_POST[jo_country]		  =  $list[rc_country];
		$_POST[jo_zip]			  =  $list[rc_zip];
		$_POST[jo_authorized]     =   "USA";
		$_POST[jo_category]       =  $list[rc_industry];
		$_POST[jo_positions]      = 1;
		$_POST[jo_type]			  = 3;
		$_POST[jo_status]         =  1;
	}
	if($_SESSION[usertype]=='employer'){
		$sql  = "SELECT * FROM pa_employer WHERE ep_id = '".$_SESSION[uid]."'";	
        $list = $DB->fetch_one_array($sql);
        $_POST[jo_copname]		  =  $list[ep_copname] ;
		$_POST[jo_copurl]		  =  $list[ep_website];
		$_POST[jo_priname]		  =  $list[ep_fname]." ".$list[ep_lname];
		$_POST[jo_priemail]		  =  $list[ep_email];
		$_POST[jo_priphone]		  =  $list[ep_phone];
		$_POST[jo_address]	      =	 $list[ep_address1];
		$_POST[jo_city]			  =  $list[ep_city];
		$_POST[jo_state]		  =  $list[ep_state];
		$_POST[jo_country]		  =  $list[ep_country];
		$_POST[jo_zip]			  =  $list[ep_zip];
		$_POST[jo_authorized]     =   "USA";
		$_POST[jo_copculture]     =  $list[ep_CompCulture];
		$_POST[jo_copbenefit]	  =  $list[ep_CompBenefits];
		$_POST[jo_category]       =  $list[ep_industry];
		$_POST[jo_positions]      = 1;
		$_POST[jo_function]       =  32;
		$_POST[jo_cat]            =  1;
		$_POST[jo_status]         =  1;
	}
}
if($country==''){
$country = 211;
}

ob_clean();
ob_start();
$cpforms->formheader(array('title'=>'Job Record','name'=>'article','extra'=>'name="postjob_q"'));

if($_SESSION[usertype]=='employer'){
$cpforms->makehidden(array('name'=>'action','value'=>'reg_job_q_foremployer'));
}else{
$cpforms->makehidden(array('name'=>'action','value'=>'reg_job_q_forrecruiter'));
}
$cpforms->gethightext(array('text'=>"Create Date",'value'=>date("m/d/Y",time()),'only'=>'1','view'=>"1"));

if($_SESSION[usertype]=='employer'){

$cpforms->getBoxes(array('one'=>1,'text'=>"Post To",'only'=>1,'name'=>"jo_contact[]",'view'=>"$view",'selected'=>empty($_POST[jo_contact])?array(2):$_POST[jo_contact],'option'=>$jobcontact_for_employer, 'notice_option'=>$jobcontact_tip_for_employer, 'text_tip'=>'Please select who may contact you regarding this job.'));

}else{

$defaultvalue = ('Premium' == $status)?array(4):array(4);
$disableArr = ('Premium' == $status)?array(4):array(4);
$_POST[jo_contact] = @array_unique(array_merge($_POST[jo_contact],array(4)));

//if standard user lock the 
$cpforms->getBoxes(array('one'=>1,'text'=>"Post To",'name'=>"jo_contact[]",'view'=>"$view",'selected'=>empty($_POST[jo_contact])?$defaultvalue:$_POST[jo_contact],'option'=>$jobcontact, 'notice_option'=>$jobcontact_tip, 'disableArr'=>$disableArr
));

}

$cpforms->makeselect(array('one'=>1,'only'=>1,'text'=>"Job Category",'name'=>"jo_cat",'selected'=>"$_POST[jo_cat]",'view'=>"$view",'option'=> $jobCatOption, 'selectextra'=>' id="jo_cat" onchange="changeOptions(\'jobsplit\')" '));
if($_POST[jo_cat] == 2) $smarty->assign('splitfee',1);
$cpforms->maketextarea(array('text'=>"Job Split Fee ($ or %)",'name'=>"jo_bonus",'value'=>"$_POST[jo_bonus]",'view'=>"$view",icon=>"'Please indicate the service fee in US dollar, or the % payout for this job split.  Please include as much detail as possible.  Once posted, you cannot change this field. If you entered a wrong number, you must delete this job and create a new one.  (Example: The payout for this is 10% of annual salary, or $5,000 total fee).',WIDTH, 200, SHADOW, true", 'trId'=>'jobsplit'));

$cpforms->gethightext(array('text'=>"Company Name",'name'=>"jo_copname",'only'=>1,'value'=>"$_POST[jo_copname]",'view'=>"$view",'icon'=>"'If you are independent and don\'t have a company name simply enter your name here.', WIDTH, 200, SHADOW, true"));

$cpforms->gethightext(array('text'=>"Job Title",'name'=>"jo_title",'only'=>1,'value'=>"$_POST[jo_title]",'view'=>"$view"));

$cpforms->makeselect(array('one'=>1,'text'=>"Job Fill Status",'only'=>1,'name'=>"jo_status",'view'=>"$view",'selected'=>"$_POST[jo_status]",'option'=> $jobfillstatus,icon=>"'Please indicate OPEN or On-Hold if you wish to receive messages.  When you change the status to CLOSED, you will stop receiving messages and candidates.  You may edit this status anytime.',WIDTH, 200, SHADOW, true"));

$cpforms->makeselect(array('one'=>1,'text'=>"Job Type",'only'=>1,'name'=>"jo_type",'view'=>"$view",'selected'=>"$_POST[jo_type]",'option'=>$jobtype));
$cpforms->makeselect(array('one'=>1,'text'=>"Job Industry",'name'=>"jo_category",'only'=>1,'selected'=>"$_POST[jo_category]",'view'=>"$view",'option'=> $jobcategory));
$cpforms->makeselect(array('one'=>1,'text'=>"Job Function",'name'=>"jo_function",'only'=>1,'selected'=>"$_POST[jo_function]",'view'=>"$view",'option'=> $jobfunction));
$cpforms->gethightext(array('text'=>"Compensation(US$)",'name'=>"jo_salrange", 'value'=>"$_POST[jo_salrange]",'only'=> '1','view'=>"$view",'icon'=>"' Please indicate the pay range for this Job order.', WIDTH, 200, SHADOW, true"));
$cpforms->gethightext(array('text'=>"Work Address",'only'=>1,'name'=>"jo_address",'value'=>"$_POST[jo_address]",'view'=>"$view"));
$cpforms->gethightext(array('text'=>"City",'name'=>"jo_city",'only'=>1,'value'=>"$_POST[jo_city]",'view'=>"$view"));
$cpforms->makeselect(array('one'=>1,'text'=>"State/Region",'name'=>"jo_state",'only'=>1,'selected'=>"$_POST[jo_state]",'view'=>"$view",'option'=> $state));
$cpforms->makeselect(array('one'=>1,'text'=>"Country",'name'=>"jo_country",'only'=>1,'selected'=>"$_POST[jo_country]",'view'=>"$view",'option'=> $country));
$cpforms->gethightext(array('text'=>"Zip Code",'name'=>"jo_zip",'only'=>1,'value'=>"$_POST[jo_zip]",'view'=>"$view"));
$cpforms->makefck(array('text'=>"Job Description",'id'=>"jo_description",'name'=>"jo_description","only"=>1,'value'=>(($_POST[jo_description]==NULL || $_POST[jo_description] == "")?"":"$_POST[jo_description]"),'view'=>"$view",'icon'=>"'You may type-in or paste your job description here. Do not include your contact information.', WIDTH, 200, SHADOW, true"));

echo '<tr class="tbhead">
<td colspan="2" align="center" bgcolor="#F0F0F0">
 <input class="bginput button-secondary" accesskey="y" type="button" name="aaaa" value=" Save "  onclick=\'document.postjob_q.target=""; document.postjob_q.action="postjob_q.php";  this.form.submit()\'  /> 
 <input class="bginput button-secondary" accesskey="r" type="button" name="" value=" Cancel "  onclick="history.back(1)"  /> 
<br></td></tr></table></td></tr></form></table>';

$reg_data = ob_get_contents();
ob_end_clean();
$title   = "Quick Add Job";
$content = "(<font color=red>*</font>=Required Field)";
$smarty->assign('title',$title);
$smarty->assign('content',$content);

if($err!=''){
$smarty->assign("err",$err);
}
$smarty->assign("reg",$reg_data);
$smarty->display('allleft.tpl');
$smarty->display('postjob_q.tpl');


$smarty->display('allright.tpl');
$smarty->display('footer.tpl');
?>
